package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;

@Controller
@RequestMapping("test")
public class TestController {

    @RequestMapping("checkName")
    public void checkName(String name,HttpServletResponse response) throws IOException {
        if("java".equals(name)){
            response.getWriter().print("no");
        }
        else{
            response.getWriter().print("yes");
        }
    }

    @RequestMapping("getString")
//    @ResponseBody
    public String getString(){
        System.out.println("访问getString");

//        return "ok中国人";
        return "/html/add.html";
    }

    @RequestMapping("getUser")
    @ResponseBody
    public UserBean getUser(HttpServletResponse response){

        return new UserBean(1,"刘三", LocalDate.parse("1998-03-04"));
    }

    @RequestMapping("getX")
    @ResponseBody
    public String getX(){
        return "3";
    }
}
